package com.tiantian.homework_5_login.utils;

import org.springframework.stereotype.Component;

import java.util.Base64;

@Component
public class Base64Util {
    /**
     * Base64编码
     */
    public static String base64(String str) {
        byte[] bytes = str.getBytes();
        // Base64 加密
        return Base64.getEncoder().encodeToString(bytes);
    }

    /**
     * Base64 解密
     */
    public static String decode(String encoded){
        byte[] decoded = Base64.getDecoder().decode(encoded);
        return new String(decoded);
    }
}
